﻿namespace Dissemination.MVC.Models
{
    using System.ComponentModel;
    using System.ComponentModel.DataAnnotations;
    using System.Web.Mvc;
    using System;

    [MetadataType(typeof(SeminarMetaData))]
    public partial class Seminar
    {
        [DisplayName("Code")]
        public string SeminarCode
        {
            get
            {
                return this.TargetArea.TargetAreaCode + "_" + this.SeminarOrdinal;
            }
        }

        public string FriendlyDate
        {
            get
            {
                return this.SeminarDate.HasValue ? this.SeminarDate.Value.ToString("dd-MM-yyyy") : string.Empty;
            }
        }

        public string FriendlyTitle
        {
            get
            {
                return string.Format("{0} - {1} - {2} - {3}", this.SeminarCode, this.SeminarCity, this.SeminarCenter, FriendlyDate);
            }
        }

        [Bind(Exclude = "SeminarID")]
        public class SeminarMetaData
        {
            [Required(ErrorMessage = "The city is required")]
            [StringLength(256)]
            [DisplayName("City")]
            public string SeminarCity { get; set; }

            [StringLength(256)]
            [DisplayName("Center")]
            public string SeminarCenter { get; set; }

            [Required(ErrorMessage = "The date is required")]
            [DisplayName("Date")]
            public DateTime? SeminarDate { get; set; }

        }
    }
}